import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/anchor_entity.dart';

AnchorEntity $AnchorEntityFromJson(Map<String, dynamic> json) {
  final AnchorEntity anchorEntity = AnchorEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    anchorEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    anchorEntity.msg = msg;
  }
  final List<AnchorData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<AnchorData>(e) as AnchorData).toList();
  if (data != null) {
    anchorEntity.data = data;
  }
  return anchorEntity;
}

Map<String, dynamic> $AnchorEntityToJson(AnchorEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension AnchorEntityExtension on AnchorEntity {
  AnchorEntity copyWith({
    int? code,
    String? msg,
    List<AnchorData>? data,
  }) {
    return AnchorEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

AnchorData $AnchorDataFromJson(Map<String, dynamic> json) {
  final AnchorData anchorData = AnchorData();
  final String? anchorName = jsonConvert.convert<String>(json['anchor_name']);
  if (anchorName != null) {
    anchorData.anchorName = anchorName;
  }
  final String? platform = jsonConvert.convert<String>(json['platform']);
  if (platform != null) {
    anchorData.platform = platform;
  }
  final String? roomId = jsonConvert.convert<String>(json['roomId']);
  if (roomId != null) {
    anchorData.roomId = roomId;
  }
  final String? openUrl = jsonConvert.convert<String>(json['open_url']);
  if (openUrl != null) {
    anchorData.openUrl = openUrl;
  }
  final String? imgUrl = jsonConvert.convert<String>(json['img_url']);
  if (imgUrl != null) {
    anchorData.imgUrl = imgUrl;
  }
  return anchorData;
}

Map<String, dynamic> $AnchorDataToJson(AnchorData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['anchor_name'] = entity.anchorName;
  data['platform'] = entity.platform;
  data['roomId'] = entity.roomId;
  data['open_url'] = entity.openUrl;
  data['img_url'] = entity.imgUrl;
  return data;
}

extension AnchorDataExtension on AnchorData {
  AnchorData copyWith({
    String? anchorName,
    String? platform,
    String? roomId,
    String? openUrl,
    String? imgUrl,
  }) {
    return AnchorData()
      ..anchorName = anchorName ?? this.anchorName
      ..platform = platform ?? this.platform
      ..roomId = roomId ?? this.roomId
      ..openUrl = openUrl ?? this.openUrl
      ..imgUrl = imgUrl ?? this.imgUrl;
  }
}